home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Instance.sea / XML Instance / Required / plugins / HTMLWindow.jar / horst / HTMLPane$ParsingThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-03-18  |  3.4 KB  |  91 lines

  1. package horst;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Cursor;
  5. import java.io.IOException;
  6. import java.io.Reader;
  7. import java.net.URL;
  8. import java.net.URLConnection;
  9. import javax.swing.JOptionPane;
  10. import javax.swing.SwingUtilities;
  11.  
  12. class HTMLPane$ParsingThread implements Runnable {
  13.    // $FF: synthetic field
  14.    private final HTMLPane this$0;
  15.    URL url;
  16.    boolean bAddToHistory;
  17.    // $FF: renamed from: r java.io.Reader
  18.    Reader field_0;
  19.  
  20.    HTMLPane$ParsingThread(HTMLPane this$0, Reader reader, URL baseURL, boolean bAddToHistory) {
  21.       this.this$0 = this$0;
  22.       this.this$0 = this$0;
  23.       this.field_0 = reader;
  24.       this.url = baseURL;
  25.       this.bAddToHistory = bAddToHistory;
  26.    }
  27.  
  28.    HTMLPane$ParsingThread(HTMLPane this$0, URL url, boolean bAddToHistory) {
  29.       this.this$0 = this$0;
  30.       this.this$0 = this$0;
  31.       this.url = url;
  32.       this.bAddToHistory = bAddToHistory;
  33.    }
  34.  
  35.    public void run() {
  36.       String contentType = "";
  37.       if (this.field_0 != null) {
  38.          if (this.this$0.beginParsing(this.field_0, this.url)) {
  39.             if (this.bAddToHistory) {
  40.                this.this$0.m_props.m_history.add(this.url);
  41.             }
  42.  
  43.             SwingUtilities.invokeLater(new HTMLPane.RenderingThread(this.this$0, this.field_0, this.url));
  44.          }
  45.  
  46.          this.this$0.m_bParsing = false;
  47.          this.this$0.setCursor(Cursor.getPredefinedCursor(0));
  48.       } else if (this.url != null) {
  49.          URLConnection con = null;
  50.  
  51.          try {
  52.             this.this$0.notifyStatusListeners(0, this.url);
  53.             con = this.url.openConnection();
  54.             contentType = con.getContentType();
  55.          } catch (IOException e) {
  56.             System.out.println("Exception : " + ((Throwable)e).getMessage());
  57.             this.this$0.m_bParsing = false;
  58.             return;
  59.          }
  60.  
  61.          if (!this.this$0.notifyStatusListeners(6, contentType)) {
  62.             this.this$0.m_bParsing = false;
  63.             return;
  64.          }
  65.  
  66.          if (contentType == null) {
  67.             contentType = "text/html";
  68.          }
  69.  
  70.          contentType.trim();
  71.          if (!"image/jpeg".equals(contentType) && !"image/gif".equals(contentType) && !"image/jpg".equals(contentType)) {
  72.             if (!contentType.startsWith("text/html") && !contentType.startsWith("text/plain")) {
  73.                JOptionPane.showMessageDialog((Component)null, "Invalid content type: " + contentType, "Error", 0);
  74.                this.this$0.notifyStatusListeners(9, this.this$0.m_document.getURL());
  75.             } else if (this.this$0.beginParsing(con)) {
  76.                if (this.bAddToHistory) {
  77.                   this.this$0.m_props.m_history.add(this.url);
  78.                }
  79.  
  80.                SwingUtilities.invokeLater(new HTMLPane.RenderingThread(this.this$0, (URL)null));
  81.             }
  82.          } else {
  83.             this.this$0.loadImageContent(this.url);
  84.          }
  85.  
  86.          this.this$0.m_bParsing = false;
  87.       }
  88.  
  89.    }
  90. }
  91.